package net.sky.oa.test.action.system;

import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import net.sky.oa.action.system.SysSchoolAction;
import net.sky.oa.test.BaseTestCase;

import org.apache.struts2.ServletActionContext;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.test.annotation.Rollback;

import com.opensymphony.xwork2.ActionContext;

public class SysSchoolAction2TestCase extends BaseTestCase {

	@Resource
	private SysSchoolAction sysSchoolAction;
	private HttpServletRequest request;

	@Before
	public void setUp() {
		request = EasyMock.createMock(HttpServletRequest.class);
		ActionContext.setContext(new ActionContext(new HashMap()));
		ServletActionContext.setRequest(request);
	}

	@After
	public void tearDown() {
		EasyMock.verify(request);
	}

	@Test
	@Rollback(false)
	public void add() {

		EasyMock.expect(request.getParameter("key")).andReturn("trilogy").once();
		EasyMock.replay(request);

		sysSchoolAction.save();

	}

	@Test
	@Rollback(false)
	public void find() {
		String result = sysSchoolAction.list();
		System.out.println("result:" + result);
		System.out.println("result:" + sysSchoolAction.getJsonString());
	}
}